import vueJsx from '@vitejs/plugin-vue-jsx';
import { fileURLToPath, URL } from 'node:url';
import AutoImport from 'unplugin-auto-import/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vitepress';
import { COMPONENTS_SIDE_BAR, HEADER_NAV } from '../../components/config';


export default defineConfig({
  title: '月亮撞火星-博客',
  head: [
    [
      'link',
      {
        rel: 'icon',
        href: 'https://tinypng.com/static/images/george-account-page.webp'
      }
    ]
  ],
  themeConfig: {
    logo: 'https://pinia.vuejs.org/logo.svg',
    search: {
      provider: 'local'
    },
    nav: HEADER_NAV,
    sidebar: COMPONENTS_SIDE_BAR,
    socialLinks: [{ icon: 'github', link: 'https://gitee.com/wang-xinlinlin/vite-press' }],
    footer: {
      message: '版权声明',
      copyright: 'Copyright © 2024 present WangXinLin'
    }
  },
  vite: {
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('../../', import.meta.url))
      }
    },
    plugins: [
      AutoImport({
        imports: ['vue', 'vue-router', 'pinia', 'vue-i18n'],
        dts: 'auto-imports.d.ts',
        dirs: ['/components', '/utils']
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      }),
      vueJsx({
        resolvers: [vueJsx()]
      })
    ],
    server: {
      proxy: {
        '/api': {
          target: 'http://shopadmin.dishawang.com/api',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '')
        }
      }
    }
  }
});
